var a = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), t = require("../../../@babel/runtime/helpers/defineProperty"), e = require("../../../@babel/runtime/helpers/asyncToGenerator"), r = getApp();

Page({
    data: {
        order_id: 0,
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1,
        another_name: {}
    },
    onLoad: function(a) {
        this.data.order_id = a.order_id, this.getListData();
    },
    onReady: function() {},
    onShow: function() {},
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            isLoadMore: !0,
            networkLoading: !1
        });
    },
    getListData: function() {
        var a = this;
        this.initData();
        var t = {
            order_id: this.data.order_id
        }, e = r.getNetAddresss("plugin.live-install.frontend.order.getRefundList");
        r._postNetWork({
            url: e,
            data: t,
            success: function(t) {
                var e = t.data;
                if (1 != e.result) return r.tips(e.msg);
                a.data.total_page = e.data.last_page, a.data.total_page || (a.data.total_page = 0), 
                a.setData({
                    listData: e.data.data,
                    another_name: e.data.another_name,
                    networkLoading: !0
                }), console.log(e);
            }
        });
    },
    _getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var t = {
                order_id: this.data.order_id,
                page: page
            }, e = r.getNetAddresss("plugin.live-install.frontend.order.getRefundList");
            r._postNetWork({
                url: e,
                data: t,
                success: function(t) {
                    var e = t.data;
                    if (a.data.isLoadMore = !0, 1 === e.result) {
                        var r = a.data.listData.concat(e.data.data);
                        a.setData({
                            listData: r
                        });
                    } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1;
                }
            });
        }
    },
    handBtnClick: function(n) {
        var i = this;
        return e(a.default.mark(function e() {
            var o, s, d, u, l;
            return a.default.wrap(function(a) {
                for (;;) switch (a.prev = a.next) {
                  case 0:
                    if (o = n.currentTarget.dataset, s = o.refund_id, d = o.btn, u = o.index, "cancelRefundApply" != d.code && "finishRefundApply" != d.code) {
                        a.next = 7;
                        break;
                    }
                    return a.next = 4, r.confirm("是否确定".concat(d.name));

                  case 4:
                    if (0 != a.sent) {
                        a.next = 7;
                        break;
                    }
                    return a.abrupt("return");

                  case 7:
                    l = r.getNetAddresss(d.api), r._postNetWork({
                        url: l,
                        data: {
                            refund_id: s
                        },
                        success: function(a) {
                            var e = a.data;
                            if (r.tips(e.msg), 1 === e.result) {
                                var n = i.data.listData;
                                if ("cancelRefundApply" == d.code) n.splice(u, 1), i.setData({
                                    listData: n
                                }); else if ("finishRefundApply" == d.code) {
                                    var o, s = "listData[" + u + "].state_name", l = "listData[" + u + "].button_group";
                                    i.setData((t(o = {}, s, "售后完成"), t(o, l, []), o));
                                }
                            }
                        }
                    });

                  case 9:
                  case "end":
                    return a.stop();
                }
            }, e);
        }))();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    bindPreviewImage: function(a) {
        var t = a.currentTarget.dataset, e = t.arr, r = t.src;
        wx.previewImage({
            urls: e,
            current: r
        });
    },
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});